/* preliminary analysis                 */
/* creating variables for analysis      */

data taxes (keep=responseid accept acceptpo acceptpr decision_acceptance policy_fairness procedure_fairness interest_considered
                          vignet 
                          climatt SES effect
                          autobezit autobezit2  /* this is a recode on the basis of three vars */
                          income_satisf est_income
                          highest_degree education
                          SES
                          residence commuting_freq work_distance_cat work_distance_km work_transportation commuting_cat
                          climatt op_serious op_serious2 climatt op_inevitable op_CO2
                          effect eff_traffic eff_sustainability eff_climate_change
                          with_c_better without_c_better uniform_better proportional_better 
                          altpro altpol test2
                          victdefeat
                          consult propuni
                          position u_prop_uni u_consult)
                          ; 
 set taxes;

/* policy acceptance */
acceptpo = sum(decision_acceptance,policy_fairness);
acceptpr = sum(procedure_fairness,interest_considered);
accept   = sum(decision_acceptance,policy_fairness,procedure_fairness,interest_considered)/2;

/* ownership car */
if autobezit in (0,1) then autobezit2 = 1;
if autobezit eq 2     then autobezit2 = 2;
if autobezit eq 3     then autobezit2 = 3;

/* income */
array income income_satisf est_income;
 do _i_ = 1 to 2;
 if income in (1,2) then income = 1;
 if income eq 3     then income = 2;
 if income in (4,5) then income = 3;
 end;

/* eduction */
if highest_degree in (1,2,3,4) then education = 1;
if highest_degree eq 5         then education = 2;
if highest_degree in (6,7)     then education = 3;

SES=sum(education,est_income,income_satisf);

/* residence */
if residence eq 8 then residence = 7;

/* commuting */
if commuting_freq eq 4 then commuting_freq = 3; 

if work_transportation eq 1       then commuting_cat = 1;
if work_transportation eq 2       then commuting_cat = 2;
if work_transportation in (3,4,5) then commuting_cat = 3;
if work_transportation eq 6       then commuting_cat = 4;
if work_transportation eq -99     then commuting_cat = 5;

/* climate change */
if op_serious eq 1 then op_serious2 = 5;
if op_serious eq 2 then op_serious2 = 4;
if op_serious eq 3 then op_serious2 = 3;
if op_serious eq 4 then op_serious2 = 2;
if op_serious eq 5 then op_serious2 = 1;

climatt=sum(op_serious2,op_inevitable,op_CO2);

effect=sum(eff_traffic,eff_sustainability,eff_climate_change);

if with_c_better       eq 1 then altpro = 'alt_pro_better_no';
if without_c_better    eq 1 then altpro = 'alt_pro_better_no';
if with_c_better       eq 2 then altpro = 'alt_pro_better_yes';
if without_c_better    eq 2 then altpro = 'alt_pro_better_yes';

if uniform_better      eq 1 then altpol = 'alt_pol_better_no';
if proportional_better eq 1 then altpol = 'alt_pol_better_no';
if uniform_better      eq 2 then altpol = 'alt_pol_better_yes';
if proportional_better eq 2 then altpol = 'alt_pol_better_yes';

if uniform_better eq 2      then victdefeat = 0;
if proportional_better eq 2 then victdefeat = 0;
if uniform_better eq 1      then victdefeat = 1;
if proportional_better eq 1 then victdefeat = 1;

if consult = 'noconsultations' and with_c_better    = 2 then position = 1; /* in a noconsultation mode respondent prefer consultations          , in favor consultation    , ifv consult     */
if consult = 'noconsultations' and with_c_better    = 1 then position = 2; /* in a noconsultation mode respondent does not prefer consultations , against consultation     , against consult */
if consult = 'consultations'   and without_c_better = 2 then position = 3; /* in a consultation mode respondent prefers no consultations,       , in favor no consultations, against consult */
if consult = 'consultations'   and without_c_better = 1 then position = 4; /* in a consultation mode respondent does not prefer no consultations, against no consultations , ifv consult     */

if altpro eq 'alt_pro_better_no' and altpol eq 'alt_pol_better_no' then test = 1;
if altpro eq 'alt_pro_better_ye' and altpol eq 'alt_pol_better_no' then test = 2;
if altpro eq 'alt_pro_better_no' and altpol eq 'alt_pol_better_ye' then test = 3;
if altpro eq 'alt_pro_better_ye' and altpol eq 'alt_pol_better_ye' then test = 4;

if vignet = 'uni/consult_v1' and altpol eq 'alt_pol_better_no' then test2 = 1;
if vignet = 'pro/consult_v2' and altpol eq 'alt_pol_better_no' then test2 = 2;
if vignet = 'uni/noconsu_v3' and altpol eq 'alt_pol_better_no' then test2 = 3;
if vignet = 'pro/noconsu_v4' and altpol eq 'alt_pol_better_no' then test2 = 4;

if vignet = 'uni/consult_v1' and altpol eq 'alt_pol_better_ye' then test2 = 5;
if vignet = 'pro/consult_v2' and altpol eq 'alt_pol_better_ye' then test2 = 6;
if vignet = 'uni/noconsu_v3' and altpol eq 'alt_pol_better_ye' then test2 = 7;
if vignet = 'pro/noconsu_v4' and altpol eq 'alt_pol_better_ye' then test2 = 8;

where u_prop_uni eq 1 and u_consult eq 1 or vignet eq 'control'; /* deleting respondents who did not understand the vignettes */

run;

